package com.lynn.boot.rabbitmqconsumer.conf;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description:
 * @Date: 2019-11-12 15:57
 * @Auther: lynn
 */
@Configuration
public class RabbitConfig {

    //队列 起名：TestDirectQueue
    @Bean
    public Queue queue() {
        return new Queue("queue", true);
    }

    //Direct交换机 起名：TestDirectExchange
    @Bean
    DirectExchange exchange() {
        return new DirectExchange("exchange");
    }

    //绑定  将队列和交换机绑定, 并设置用于匹配键：TestDirectRouting
    @Bean
    Binding bindingDirect() {
        return BindingBuilder.bind(queue()).to(exchange()).with("queue");
    }
}
